package com.zjl.spring.thread;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Auther: zhuangjl
 * @Date: 2021/11/08 15:48
 */
public class TicketWindowRunnable implements Runnable {

    private static AtomicInteger ticketCount = new AtomicInteger(100);

    @Override
    public void run() {

        while (ticketCount.decrementAndGet() >=0) {
            System.out.println(Thread.currentThread().getName() + "：买到一张票，"+"还剩"+ticketCount.get()+"张票");
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
